<?php

namespace app\admin\model;

use think\Model;


class UserLevelSetting extends Model
{
    // 表名
    protected $name = 'user_level_setting';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'unfreeze_text'
    ];
    public function getUnfreezeList()
    {
        return ['1' => __('Unfreeze 1'), '0' => __('Unfreeze 0')];
    }
    public function getUnfreezeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['unfreeze']) ? $data['unfreeze'] : '');
        $list = $this->getUnfreezeList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    //关联等级详情表
    public function leveldetail()
    {
        return $this->hasMany('app\admin\model\LevelDetail','user_level_setting_id','id');
    }
}
